// stores/consult.ts
import { ref } from 'vue'
import { defineStore } from 'pinia'
import { ConsultInfo } from '@/types/patient'

export const useConsultStore = defineStore(
  'consult',
  () => {
    // 患者病情初始数据
    const initValue = {
      illnessDesc: '',
      illnessTime: 1,
      consultFlag: 0,
      pictures: [],
    }
    // 患者病情数据
    const illnessInfo = ref<ConsultInfo>({
      ...initValue,
    })
    // 重置数据
    const clear = () => {
      depId.value = ''
      type.value = ''
      patientId.value = ''
      illnessType.value = ''
      illnessInfo.value = { ...initValue }
    }
    // 患者ID
    const patientId = ref('')
    const setPatientId = (id: string) => {
      patientId.value = id
    }

    const setIllnessInfo = (obj: ConsultInfo) => {
      illnessInfo.value = obj
    }
    // 医生id
    const docId = ref('')
    const setDocId = (id: string) => {
      docId.value = id
    }
    // 科室id
    const depId = ref('')
    const setDepId = (id: string) => {
      depId.value = id
    }
    // 极速问诊级别 0 普通 1 三甲
    const illnessType = ref('')
    const setIllnessType = (value: string) => {
      illnessType.value = value
    }

    // 问诊类型  1 找医生  2 极速问诊  3 图文问诊
    const type = ref('')
    const setType = (value: string) => {
      type.value = value
    }

    return {
      illnessInfo,
      setIllnessInfo,
      patientId,
      setPatientId,
      depId,
      setDepId,
      illnessType,
      setIllnessType,
      type,
      setType,
      clear,
    }
  },
  {
    unistorage: true,
  }
)
